package com.proj.hot;

import android.app.Application;
import android.content.Context;
import android.os.Process;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.proj.hot.utils.ImageLoaderConfigFactory;

import org.xutils.x;

/**
 * Created by zangchenggang on 17/6/26.
 */
public class ProOttApplication extends Application implements
        Thread.UncaughtExceptionHandler{
    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);
        x.Ext.setDebug(false);
        ImageLoader.getInstance().init(
                ImageLoaderConfigFactory.
                        getDefaultConfig(this));

    }
    /**
     * 内存消耗过大时，进行垃圾回收
     */
    @Override
    public void onLowMemory() {
        // TODO Auto-generated method stub
        Runtime.getRuntime().gc();
        super.onLowMemory();
    }

    /**
     * 出现没有捕获的异常时，杀掉进程
     */
    @Override
    public void uncaughtException(Thread arg0, Throwable arg1) {
        // TODO Auto-generated method stub
        android.os.Process.killProcess(Process.myPid());
    }

    /**
     * 模拟过程环境，电视上不会被调用
     */
    @Override
    public void onTerminate() {
        // TODO Auto-generated method stub
        super.onTerminate();
    }

    /**
     * 环境创建的时候被调用
     */
    @Override
    protected void attachBaseContext(Context base) {
        // TODO Auto-generated method stub
        super.attachBaseContext(base);
    }

}
